
import validate from 'wechat-validate'

Page({
  behaviors: [validate],
  data:{
    mobile:'',
    code:'',
    timeData:{},
    getCodeBtnVisible:true
  },
  rules: {
    mobile: [
      { required: true, message: '请填写手机号码!' },
      { pattern: /^1[3-8]\d{9}$/, message: '请检查手机号码是否正确!' },
    ],
    code: [
      { required: true, message: '请填写短信验证码!' },
      { pattern: /^\d{6}$/, message: '请检查短信验证码是否正确!' }
    ]
  },
  getSMSCode(){
    this.setData( {getCodeBtnVisible:false})
  },
  countDownChange(ev){
console.log(ev)
const d = ev.detail
this.setData({
  timeData: d,
  getCodeBtnVisible: d.minutes === 0 && d.seconds === 0
})
  },
  mobileqq(){
    const { valid, message } = this.validate('mobile')
    if(!valid){
      wx.$toast(message)
      return
    }  
  },
  codeqq(){
    const { valid, message } = this.validate('code')
    if(!valid){
      console.log(valid)
      wx.$toast(message)
      return
    }  
  }
})